<template>
  <div class="class-detail">
    <class-main v-if="showList" :statusId="statusId" />
    <stage-dialog
      :visible-dialog="stageDialog"
      :statusId="statusId"
      @closeAddStage="stageDialog= false"
    />
    <class-dialog
      :visible-dialog="classDialog"
      :statusId="statusId"
      @closeDialog="closeDialog"
      @closeAddClass="classDialog= false"
    />
    <div class="button-wrap">
      <el-button @click="backStep">上一步</el-button>
      <el-button type="primary" @click="nextStep">保存</el-button>
      <el-button @click="handleCancel">取消</el-button>
    </div>
  </div>
</template>

<script>
import classMain from "./classdetail/complextable";
import stageDialog from "./classdetail/stageDialog";
import classDialog from "./classdetail/classDialog";
import { pushMessageBus } from "./eventbus";

export default {
  props: {
    statusId: {
      type: Number,
      // required: true//必须进行传值
      default: 0
    }
  },
  components: {
    classMain,
    stageDialog,
    classDialog
  },
  data() {
    return {
      stageDialog: false,
      classDialog: false,
      showList: true
    };
  },
  nextStep() {
    this.$emit("classNext");
  },
  mounted() {
    pushMessageBus.$on("fromStep-openAddStage", () => {
      this.stageDialog = true;
    });
    pushMessageBus.$on("fromStep-openAddClass", () => {
      this.classDialog = true;
    });
  },
  methods: {
    backStep() {
      this.$emit("classBack");
    },
    nextStep() {
      this.$router.push('/subject/classpackage');
    },
    closeDialog() {
      this.classDialog = false;
      // this.$emit('classBack')
      this.$emit("secondGoNext", this.statusId);
      this.showList = false;
      setTimeout(() => {
        this.showList = true;
      }, 10);
    },
    handleCancel() {
      this.$router.go(-1);
    }
  }
};
</script>

<style lang="scss">
.class-detail {
  .button-wrap {
    margin-top: 40px;
  }
}
</style>
